import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../base/base_state.dart';
import '../../components/LoginTextField.dart';
import '../../components/LoginTextFieldColor.dart';
import '../../resources.dart';

import 'model/change_password_model.dart';

/// created by hcl
/// on 2024/2/27
/// ChangePasswordPage
/// desc
class ChangePasswordPage extends StatefulWidget {
  const ChangePasswordPage({super.key});

  @override
  State<StatefulWidget> createState() => _ChangePasswordState();
}

class _ChangePasswordState
    extends BaseState<ChangePasswordModel, ChangePasswordPage> {
  @override
  String get title => word.mine_password;

  @override
  ChangePasswordModel initModel() {
    return ChangePasswordModel();
  }

  @override
  Widget bodyWidget(BuildContext context) {
    return Consumer<ChangePasswordModel>(
        builder: (BuildContext context, model, Widget? child) {
      return Container(
        padding: EdgeInsets.only(
            top: 30.ss, bottom: 12.ss, left: 13.5.ss, right: 13.5.ss),
        child: Column(
          children: [
            LoginTextFieldColor(
              model.oldPasswordController,
              model.oldPasswordFocusNode,
              word.please_enter_old_password,
              keyboardType: TextInputType.visiblePassword,
              showPassword: true,
            ),
            SizedBox(height: 27.ss),
            LoginTextFieldColor(
              model.newPasswordController,
              model.newPasswordFocusNode,
              word.please_enter_new_password,
              keyboardType: TextInputType.visiblePassword,
              showPassword: true,
            ),
            SizedBox(height: 27.ss),
            LoginTextFieldColor(
              model.confirmPasswordController,
              model.confirmPasswordFocusNode,
              word.please_enter_confirm_password,
              keyboardType: TextInputType.visiblePassword,
              showPassword: true,
            ),
            const Spacer(),
            commonButton(() {
              hideKeyboard();
              model.change();
            }, word.confirm),
          ],
        ),
      );
    });
  }
}
